package cn.edu.tju.wallet.dto;

import cn.edu.tju.wallet.domain.Transaction;
import cn.edu.tju.wallet.domain.Transaction.TransactionStatus;
import cn.edu.tju.wallet.domain.Transaction.TransactionType;
import java.math.BigDecimal;
import java.time.LocalDateTime;

public class TransactionDTO {
    // 对应Transaction实体核心字段（指南隐含要求）
    private Long id;
    private Long walletId;
    private TransactionType type;
    private BigDecimal amount;
    private BigDecimal balanceBefore;
    private BigDecimal balanceAfter;
    private TransactionStatus status;
    private Long relatedTransactionId;
    private Long orderId;
    private String remark;
    private LocalDateTime createTime;

    // 构造函数（指南要求：new TransactionDTO(transaction)）
    public TransactionDTO(Transaction transaction) {
        this.id = transaction.getId();
        this.walletId = transaction.getWalletId();
        this.type = transaction.getType();
        this.amount = transaction.getAmount();
        this.balanceBefore = transaction.getBalanceBefore();
        this.balanceAfter = transaction.getBalanceAfter();
        this.status = transaction.getStatus();
        this.relatedTransactionId = transaction.getRelatedTransactionId();
        this.orderId = transaction.getOrderId();
        this.remark = transaction.getRemark();
        this.createTime = transaction.getCreateTime();
    }

    // Getter、Setter（接口返回需序列化）
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public Long getWalletId() { return walletId; }
    public void setWalletId(Long walletId) { this.walletId = walletId; }
    public TransactionType getType() { return type; }
    public void setType(TransactionType type) { this.type = type; }
    public BigDecimal getAmount() { return amount; }
    public void setAmount(BigDecimal amount) { this.amount = amount; }
    public BigDecimal getBalanceBefore() { return balanceBefore; }
    public void setBalanceBefore(BigDecimal balanceBefore) { this.balanceBefore = balanceBefore; }
    public BigDecimal getBalanceAfter() { return balanceAfter; }
    public void setBalanceAfter(BigDecimal balanceAfter) { this.balanceAfter = balanceAfter; }
    public TransactionStatus getStatus() { return status; }
    public void setStatus(TransactionStatus status) { this.status = status; }
    public Long getRelatedTransactionId() { return relatedTransactionId; }
    public void setRelatedTransactionId(Long relatedTransactionId) { this.relatedTransactionId = relatedTransactionId; }
    public Long getOrderId() { return orderId; }
    public void setOrderId(Long orderId) { this.orderId = orderId; }
    public String getRemark() { return remark; }
    public void setRemark(String remark) { this.remark = remark; }
    public LocalDateTime getCreateTime() { return createTime; }
    public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
}